package com.andong.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

import static com.andong.utils.SystemConstant.CREATE_TIME;
import static com.andong.utils.SystemConstant.UPDATE_TIME;

/**
 * ClassName: MyMetaObjectHandler
 * @原数据处理器 自定义原数据对象处理器
 * @author XHU_WHY
 * @version V1.0
 * @since 2023/12/31 12:05
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue(CREATE_TIME, LocalDateTime.now());
        metaObject.setValue(UPDATE_TIME, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue(UPDATE_TIME, LocalDateTime.now());
    }
}
